home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************
- * *
- * Copyright (c) 1992, 1993 Ronald Joe Record *
- * *
- * All rights reserved. No part of this program or publication may be *
- * reproduced, transmitted, transcribed, stored in a retrieval system, *
- * or translated into any language or computer language, in any form or *
- * by any means, electronic, mechanical, magnetic, optical, chemical, *
- * biological, or otherwise, without the prior written permission of: *
- * *
- * Ronald Joe Record (408) 458-3718 *
- * 212 Owen St., Santa Cruz, California 95062 USA *
- * *
- *************************************************************************/
-
- /*************************************************************************
- * *
- * Copyright (c) 1989 Hiram Clawson *
- * *
- * All rights reserved. No part of this program or publication may be *
- * reproduced, transmitted, transcribed, stored in a retrieval system, *
- * or translated into any language or computer language, in any form or *
- * by any means, electronic, mechanical, magnetic, optical, chemical, *
- * biological, or otherwise, without the prior written permission of: *
- * *
- * Hiram Clawson (408) 429-5647 *
- * P. O. Box 3178, Santa Cruz, California 95063-3178 USA *
- * *
- *************************************************************************/
- /*************************************************************************
- * viewcnst.c: Setup viewing constants for the 3D plotting system *
- * *
- * Written by Hiram Clawson. *
- * Ported to X11 by Ronald Joe Record. *
- *************************************************************************/
-
- #include "globals.h"
-
- void view_point_constants()
- {
- triple v_view_upper_right;
- double length_view_upper_right;
-
- /*
- following subroutine computes constants of viewing situation
- must be done each time the viewing situation changes
- (When the viewing window moves, or the viewpoint is moved (FOV change))
- */
- v_view_center.x = window_center.x - view_point.x;
- v_view_center.y = window_center.y - view_point.y;
- v_view_center.z = window_center.z - view_point.z;
-
- v_center_right.x = window_right.x - window_center.x;
- v_center_right.y = window_right.y - window_center.y;
- v_center_right.z = window_right.z - window_center.z;
-
- v_view_upper_right.x = window_upper_right.x - view_point.x;
- v_view_upper_right.y = window_upper_right.y - view_point.y;
- v_view_upper_right.z = window_upper_right.z - view_point.z;
-
- length_view_center = sqrt( (v_view_center.x * v_view_center.x) +
- (v_view_center.y * v_view_center.y) +
- (v_view_center.z * v_view_center.z) );
-
- length_center_right = sqrt( (v_center_right.x * v_center_right.x) +
- (v_center_right.y * v_center_right.y) +
- (v_center_right.z * v_center_right.z) );
-
- length_view_upper_right = sqrt(
- (v_view_upper_right.x * v_view_upper_right.x) +
- (v_view_upper_right.y * v_view_upper_right.y) +
- (v_view_upper_right.z * v_view_upper_right.z) );
-
- v_center_top.x = window_top.x - window_center.x;
- v_center_top.y = window_top.y - window_center.y;
- v_center_top.z = window_top.z - window_center.z;
-
- length_center_top = sqrt (
- (v_center_top.x * v_center_top.x) +
- (v_center_top.y * v_center_top.y) +
- (v_center_top.z * v_center_top.z) );
- /* establish scale between 3D space units and pixel units on the screen */
- _3D_units_per_ypixel = (length_center_top/2.0) / screen_center.y;
- /*
- the angle between v_view_center and v_view_upper_right will be the
- maximum angle from the center that can be plotted (some points will miss
- because that is the upper right corner)
- */
- cosine_half_field_of_view = ( (v_view_center.x * v_view_upper_right.x) +
- (v_view_center.y * v_view_upper_right.y) +
- (v_view_center.z * v_view_upper_right.z) ) /
- (length_view_center * length_view_upper_right);
-
- field_of_view = 2.0 * acos( cosine_half_field_of_view );
-
- return;
-
- } /* end of view_point_constants */
-